/**
 * 
 */
package org.acsis.covoiturage.frontend.validators;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Abdellah
 *
 */
public class InscriptionValidator {
	
	static public boolean UserNotValid(String user){
		Pattern pattern = Pattern.compile("^[A-Za-z0-9_-]{3,16}$");
		Matcher matcher = pattern.matcher(user);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
	
	static public boolean motDePasseNotValid(String motdepasse){
		Pattern pattern = Pattern.compile("^[a-z0-9A-Z_-]{6,18}$");
		Matcher matcher = pattern.matcher(motdepasse);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
	static public boolean nomNotValid(String nom){
		Pattern pattern = Pattern.compile("[a-zA-Z']");
		Matcher matcher = pattern.matcher(nom);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
	
	static public boolean emailNotValid(String email){
		Pattern pattern = Pattern.compile("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)+$");
		Matcher matcher = pattern.matcher(email);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
	
	static public boolean dateNotValid(String date){
		Pattern pattern = Pattern.compile("^((0[1-9]|1\\d|2[0-8])/(0\\d|1[012])/(1[6-9]|[2-9]\\d)\\d{2}|(29|30)/(0[13-9]|1[012])/(1[6-9]|[2-9]\\d)\\d{2}|31/(0[13578]|1[02])/(1[6-9]|[2-9]\\d)\\d{2}|29/02/((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00))$");
		Matcher matcher = pattern.matcher(date);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
}
